package cn.com.dhc.danlu.util;

import android.text.TextUtils;

import cn.com.dhc.danlu.constant.UrlConst;

import static cn.com.dhc.danlu.dlware.global.DanluApplication.agent;

/**
 * @author: 李一方
 * @time: 2016-10-12 17:12
 * @mail: liyifang@danlu.com
 * @desc: 链接操作的相关工具类
 */
public class UrlUtil {
    /**
     * 获取活动中心的默认链接
     *
     * @param originalUrl
     *         原始链接
     * @return 拼接参数后的链接
     */
    public static String getActivityUrl (String originalUrl) {
        if (TextUtils.isEmpty (originalUrl)) {
            return UrlConst.URL_DEFAULT + getParamsUrl ();
        } else {
            return originalUrl + getParamsUrl ();
        }
    }

    private static String getParamsUrl () {
        return "?token=" + agent.getToken () +
                "&user_id=" + agent.getLoginUser ().getUserId () +
                "&jsessionid=" + agent.getLoginUser ().getSessionId () +
                "&company_id=" + agent.getLoginUser ().getCompanyId ();
    }
}
